#pragma once
#include <string>
#include <set>
#include "afxwin.h"

namespace Sensor {

	class SerialPortReader {
	private:
		unsigned int bufferSize;
		HANDLE handle;
		DCB config;

		SerialPortReader();
		static std::string getPortFilename(int port);
	public:
		static std::set<int> getPorts();

		SerialPortReader(unsigned int bufferSize);
		~SerialPortReader();
		void setBaudRate(int buadRate);
		void setBufferSize(int bufferSize);

		void open(int port);
		void open(std::string portName);
		
		/*
		Synchronous read.
		*/
		std::string readLine();

		void close();
	};

};
